<template>
  <article class="page mine-page">
    <div class="header">
      <div @click="tools.back()" class="back"><span class="arrow"></span></div>
      <div class="head-bd">
        积分明细
      </div>
      <!--<div @click="detail()" class="message"><div class="head-btn-text">积分规则</div></div>-->
    </div>
    <section class="frame-content-sub no-bg">
      <div class="score-hd">
        <h1 class="score">{{myIntegrals.totalScore}}</h1>
        <p class="tip">当前积分，继续努力</p>
      </div>

      <section class="block score-detail">
        <div class="item" v-for="item in list">
          <div class="cont">
            <h1 class="title">{{item.name}}</h1>
            <div class="tip">{{tools.formateYearSecond(item.createTime)}}</div>
          </div>
          <div class="color-red">+{{item.score}}分/次</div>
        </div>
        <div class="item">
          <div class="cont">
            <h1 class="title">登陆客服端</h1>
            <div class="tip">2020-5-10</div>
          </div>
          <div class="color-red">+2分/次</div>
        </div>
        <div class="item">
          <div class="cont">
            <h1 class="title">登陆客服端</h1>
            <div class="tip">2020-5-10</div>
          </div>
          <div class="color-red">+2分/次</div>
        </div>
      </section>



      <div class="pdv-3"></div>
      <div class="pdv-3"></div>
      <div class="pdv-3"></div>
      <div class="pdv-3"></div>

    </section>
  </article>
</template>

<script>
  import progressBar from '@/components/common/progressBar.vue'
  import moment from 'moment'
  import tools from '@/utils/tools'
  import api from '@/common/config/api'
  export default {
    components: {progressBar},
    name: 'personalcenter',
    data () {
      return {
        fn: tools,
        userInfo: {},
        partyInfo: {},
        sysFile: {},
        myIntegrals: {},
        list: []
      }
    },
    created () {
      this.userInfo = this.$localStorage.get('userInfo')
      this.myIntegral()
      this.getList()
    },
    methods: {
      detail () {
        this.$router.push({path: 'pointsDetails'})
      },
      go (path) {
        this.$router.push({path: path})
      },
      getTime (createTime) {
        if (!createTime) {
          return ''
        }
        return moment(createTime).format('MM月DD日')
      },
      myIntegral () {
        let data = {
          userId: this.userInfo.id
        }
        this.fetchService.myIntegral(data.userId).then(res => {
          if (res.code !== 0) {
            return tools.tip(res.message)
          }
          this.myIntegrals = res.data
        })
      },
      getList () {
        let params = {
          userId: this.userInfo.id
        }
        this.fetchService.detailList(params).then(res => {
          if (res.code !== 0) {
             return tools.tip(res.message)
          }
          this.list = res.data
        })
      },
      showImg (fileId) {
        let fileUrl = this.tools.getImgUrl(fileId)
        console.log('-------------fileUrl=', fileUrl)
        return fileUrl
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "@/common/stylus/moon.scss";
  .mine-page{
    background: url("../../../../static/images/dangjian/mine/bg-mine-hd.png") $bg-color no-repeat center #{pxToRem($head-height)};
    background-size: 100% auto;
    padding:0;
    .header {
      justify-content: space-between;
      margin-bottom: pxToRem(0px);
      position: relative;
    }
  }

  .score-hd {
    height:242px;
    text-align: center;
    background: url("../../../../static/images/dangjian/mine/bg-mine-hd.png") $theme-color no-repeat center;
    background-size: 100% auto;
    .score {
      font-size:56px;
      line-height:1em;
      font-weight:400;
      color:rgba(255,255,255,1);
      padding-top:50px;
    }
    .tip {
      font-size:12PX;
      font-weight:400;
      color:rgba(255,255,255,1);
    }
  }

  .score-detail {
    position: relative;
    margin-top:-60px;
    background:#fff;
    padding:29px 34px;
    margin-bottom:0;
    .item {
      display:flex;
      justify-content:space-between;
      align-items:center;
      padding:27px 0;
      border-bottom:1px solid $border-color;
      &:last-child {
        border:none;
      }
      .cont {
        .title {
          font-size:30px;
          line-height: 1em;
          font-weight:400;
          color:rgba(51,51,51,1);
          padding-bottom:10px;
        }
        .tip {
          font-size:$tipFontSize;
          font-weight:400;
          color:rgba(153,153,153,1);
        }
      }
      .color-red {
        font-size:30px;
      }
    }
  }
</style>
